<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../publics/jstl.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <title>运营管理平台-车辆管理</title>
    <link href="${ctx}/resource/publics/jquery-easyui-1.4.4/themes/default/easyui.css" rel="stylesheet" type="text/css">
    <link href="${ctx}/resource/publics/jquery-easyui-1.4.4/themes/icon.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="${ctx}/resource/publics/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script type="text/javascript" src="${ctx}/resource/publics/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
    <script type="text/javascript">
        //修改模糊查询方式
        $.fn.combobox.defaults.filter = function(q, row){
            var opts = $(this).combobox('options');
            return row[opts.textField].indexOf(q) >= 0;
        }
    </script>
</head>
<body>
<table id="dg" title="" style="width:100%"></table>
<div id="tb" style="padding:2px 5px;">
    <a href="javascript:void(0)" onclick="showAddWin()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">新建</a>
    <a href="javascript:void(0)" onclick="showEditWin()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">编辑</a>
    <a href="javascript:void(0)" onclick="del()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-remove'">删除</a>
    <a href="javascript:void(0)" onclick="showAddPriceWin()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">配置价格</a>
    <a href="javascript:void(0)" onclick="showBindWin()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'">绑定设备</a>
</div>
<div id="addWin" class="easyui-window" title="新建" data-options="closed:true,inline:false,iconCls:'icon-add'" style="width:100%;max-width:450px;padding:10px 0px 10px 15px;">
    <div style="margin-bottom:20px">
        <form id="addForm" method="post" enctype="multipart/form-data">
            <div style="margin-bottom:10px">
                <label>车辆名称：</label>
                <input id="name" name="name" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>车辆描述：</label>
                <input id="description" name="description" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>预览地址：</label>
                <input id="viewUrl" name="viewUrl" class="easyui-textbox" style="width:200px;">
            </div>
            <div style="margin-bottom:10px">
                <label>车辆状态：</label>
                <select id="status" name="status" class="easyui-combobox" style="width:200px;">
                    <option value="0">可用</option>
                    <option value="1">已预订</option>
                    <option value="2">不可用</option>
                </select>
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>车辆分类：</label>
                <select id="carflag" name="flag" class="easyui-combobox" style="width:200px;">
                    <option value="0">自有车辆</option>
                    <option value="1">已售车辆</option>
                    <option value="2">托管车辆</option>
                </select>
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>车辆保险：</label>
                <input id="insurance" name="insurance" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*) 如：200元，填：200</label>
            </div>
            <div style="margin-bottom:10px">
                <label>可预定车辆数量：</label>
                <input id="carNum" name="carNum" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*) 如：10</label>
            </div>
            <div style="margin-bottom:10px">
                <label>车辆备注：</label>
                <input id="remark" name="remark" class="easyui-textbox" data-options="multiline:true" style="width:200px; height: 60px;">
            </div>
            <div style="margin-top:10px">
                <label>车辆图片：</label>
                <input id="file" name="file" class="easyui-filebox" style="width:200px" data-options="buttonText:'选择图片'">
                <label style="color: red">(*)</label>
            </div>
        </form>
    </div>
    <div style="text-align:center;padding:5px 0">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="submitAddWin()" style="width:80px">提交</a>
    </div>
</div>
<div id="editWin" class="easyui-window" title="编辑" data-options="closed:true,inline:false,iconCls:'icon-edit'" style="width:100%;max-width:450px;padding:10px 0px 10px 15px;">
    <div style="margin-bottom:20px">
        <form id="editForm" method="post" enctype="multipart/form-data">
            <input id="edit-id" name="id" type="hidden" value=""/>
            <div style="margin-bottom:10px">
                <label>车辆名称：</label>
                <input id="edit-name" name="name" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>车辆描述：</label>
                <input id="edit-description" name="description" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>预览地址：</label>
                <input id="edit-viewUrl" name="viewUrl" class="easyui-textbox" style="width:200px;">
            </div>
            <div style="margin-bottom:10px">
                <label>车辆状态：</label>
                <select id="edit-status" name="status" class="easyui-combobox" style="width:200px;">
                    <option value="0">可用</option>
                    <option value="1">已预订</option>
                    <option value="2">不可用</option>
                </select>
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>车辆分类：</label>
                <select id="carflag" name="flag" class="easyui-combobox" style="width:200px;">
                    <option value="0">自有车辆</option>
                    <option value="1">已售车辆</option>
                    <option value="2">托管车辆</option>
                </select>
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>车辆保险：</label>
                <input id="edit-insurance" name="insurance" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*) 如：200元，填：200</label>
            </div>
            <div style="margin-bottom:10px">
                <label>可预定车辆数量：</label>
                <input id="edit-carNum" name="carNum" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*) 如：10</label>
            </div>
            <div style="margin-bottom:10px">
                <label>车辆备注：</label>
                <input id="edit-remark" name="remark" class="easyui-textbox" data-options="multiline:true" style="width:200px; height: 60px;">
            </div>
            <div style="margin-top:10px">
                <label>车辆图片：</label>
                <input id="edit-file" name="file" class="easyui-filebox" style="width:200px" data-options="buttonText:'选择图片'">
            </div>
        </form>
    </div>
    <div style="text-align:center;padding:5px 0">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="submitEditWin()" style="width:80px">提交</a>
    </div>
</div>
<div id="addPriceWin" class="easyui-window" title="添加价格" data-options="closed:true,inline:false,iconCls:'icon-add'" style="width:100%;max-width:600px;padding:10px 0px 10px 15px;">
    <div style="margin-bottom:20px">
        <form id="addPriceForm">
            <%--<div style="margin-bottom:10px">--%>
                <%--<label>价格名称：</label>--%>
                <%--<input id="price-name" class="easyui-textbox" style="width:200px;" readonly="readonly" value="日常价">--%>
                <%--<label style="color: red">(*)</label>--%>
            <%--</div>--%>
            <div style="margin-bottom:10px">
                <label>日常价格：</label>
                <input id="price" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>周末溢价：</label>
                <input id="rate-weekend" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)（如溢价100元，填：100.00）</label>
            </div>
            <div style="margin-bottom:10px">
                <label>天数1：</label>
                <input id="day1" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)（对应：天数1-天数2 的折扣，不含天数2）</label>
            </div>
            <div style="margin-bottom:10px">
                <label>折扣1：</label>
                <input id="rate1" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)（如8折，填：0.80）</label>
            </div>
            <div style="margin-bottom:10px">
                <label>天数2：</label>
                <input id="day2" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)（对应：天数2-天数3 的折扣，不含天数3）</label>
            </div>
            <div style="margin-bottom:10px">
                <label>折扣2：</label>
                <input id="rate2" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)（如7折，填：0.70）</label>
            </div>
            <div style="margin-bottom:10px">
                <label>天数3：</label>
                <input id="day3" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)（对应：天数3及以上的折扣，含天数3）</label>
            </div>
            <div style="margin-bottom:10px">
                <label>折扣3：</label>
                <input id="rate3" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)（如6折，填：0.60）</label>
            </div>
            <div style="margin-bottom:10px">
                <label>最高会员折扣：</label>
                <input id="topVipRate" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)（如5折，填：0.50）</label>
            </div>
            <%--<div style="margin-bottom:10px">--%>
                <%--<label>排序：</label>--%>
                <%--<input id="price-orderBy" class="easyui-textbox" style="width:200px;">--%>
                <%--<label style="color: red">(*)</label>--%>
            <%--</div>--%>
        </form>
    </div>
    <div style="text-align:center;padding:5px 0">
        <input id="price-car-id" name="price-car-id" type="hidden" value=""/>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="submitAddPriceWin()" style="width:80px">提交</a>
    </div>
</div>
<!-- 绑定设备 -->
<div id="bindWin" class="easyui-window" title="绑定设备" data-options="closed:true,inline:false,iconCls:'icon-add'" style="width:100%;max-width:450px;padding:10px 0px 10px 15px;">
    <div style="margin-bottom:20px">
        <form id="bindForm" method="post" enctype="multipart/form-data">
            <div style="margin-bottom:10px">
                <label>车辆标识：</label>
                <input id="bindCarId" name="id" class="easyui-textbox" style="width:200px;" data-options="readonly:true,editable:false">
            </div>
            <div style="margin-bottom:10px">
                <label>车辆名称：</label>
                <input id="bindCarName" name="name" class="easyui-textbox" style="width:200px;" data-options="readonly:true,editable:false,disabled:true">
            </div>
            <div style="margin-bottom:10px">
                <label>车辆描述：</label>
                <input id="bindCarDescription" name="description" class="easyui-textbox" style="width:200px;" data-options="readonly:true,editable:false,disabled:true">
            </div>
            <div style="margin-bottom:10px">
                <label>设备ID：</label>
                <input id="bindDeviceId" name="deviceId" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>设备编号：</label>
                <input id="bindDeviceNumber" name="deviceNumber" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)</label>
            </div>
            <div style="margin-bottom:10px">
                <label>设备名称：</label>
                <input id="bindDeviceName" name="deviceName" class="easyui-textbox" style="width:200px;">
                <label style="color: red">(*)</label>
            </div>
        </form>
    </div>
    <div style="text-align:center;padding:5px 0">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="submitBindWin()" style="width:80px">提交</a>
    </div>
</div>
<div id="showBigImage" style="position:absolute;display:none;border:1px solid silver;background:silver;z-index:9999999;">
    <img src="" style="max-height:180px;" />
</div>
<script type="text/javascript">
$('#dg').datagrid({
    title:'车辆管理',
    border:false,
    fit:true,
    fitColumns:false,
    scrollbarSize:18,
    singleSelect:true,
    method:'post',
    url:'${ctx}/manage/car/getCarList',
    idField:'id',
    toolbar:'#tb',
    pagination: true,
    columns:[[
        {field:'id',title:'车辆ID',align:'center',width:45},
        {field:'name',title:'车辆名称',align:'center',width:100},
        {field:'picUrl',title:'车辆图片',align:'center',width:100,formatter:function(value,row,index){
            var imageUrl = "${baseFileUrl}" + value;
            return '<img src="'+ imageUrl + '"' + ' height="30px" onmouseover="showBigImage(\'' + imageUrl + '\',this);" onmouseout="hideBigImage();" />';
        }},
        {field:'description',title:'车辆描述',align:'center',width:200},
        {field:'insurance',title:'车辆保险',align:'center',width:200},
        {field:'carNum',title:'可预定车辆数量',align:'center',width:200},
        {field:'viewUrl',title:'车辆预览地址',align:'center',width:200},
        {field:'status',title:'车辆状态',align:'center',width:70,formatter: function(value,row,index){
            if (value == 0){
                return '可用';
            } else if (value == 1) {
                return '已预订';
            } else {
                return '不可用';
            }
        }},
        {field:'createTime',title:'创建时间',align:'center',width:125},
        {field:'remark',title:'车辆备注',align:'center',width:100},
        {field:'deviceId',title:'设备ID',align:'center',width:180,formatter: function(value,row,index){
            <%--if (value != '' && value != 'null' && value != undefined) {--%>
                <%--return '<a href="${ctx}/manage/resource/html/dw/baidu.html?deviceNumber=' + value + '" target="_blank">' + value + '</a>';--%>
            <%--} else {--%>
                <%--return '';--%>
            <%--}--%>
        }},
        {field:'deviceNumber',title:'设备编号',align:'center',width:100},
        {field:'deviceName',title:'设备名称',align:'center',width:100},
        {field:'flag',title:'车辆分类',align:'center',width:70,formatter: function(value,row,index){
            if (value == 0){
                return '自有车辆';
            } else if (value == 1) {
                return '已售车辆';
            } else {
                return '托管车辆';
            }
        }},
        {field:'prices',title:'价格配置信息',align:'left',width:300,formatter: function(value,row,index){
            var p = '';
            for(var i=0;i<value.length;i++){
                p += '<label>'+value[i].priceDesc+'：'+value[i].price+'￥</lable>&nbsp;&nbsp;<label>周末溢价：'+value[i].rateWeekend+'</lable>' +
                        '<br><label>天数1：'+value[i].day1+'</lable>&nbsp;&nbsp;<label>折扣1：'+value[i].rate1+'</lable>' +
                        '<br><label>天数2：'+value[i].day2+'</lable>&nbsp;&nbsp;<label>折扣2：'+value[i].rate2+'</lable>' +
                        '<br><label>天数3：'+value[i].day3+'</lable>&nbsp;&nbsp;<label>折扣3：'+value[i].rate3+'</lable>' +
                        '<br><label>最高会员折扣：' + (value[i].topVipRate == null ? '' : value[i].topVipRate) +'</lable>' +
                        '<a style="margin-left: 5px;" href="javascript:void(0);" onclick="delPrice('+value[i].id+')">删除配置</a><br>';
            }
            return p;
        }}
    ]]
});
$('#dg').datagrid('getPager').pagination({
    pageSize: 10,
    pageList: [10, 15, 20],
    beforePageText: '第',
    afterPageText: '页    共 {pages} 页',
    displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
});
//新建
function showAddWin() {
    $('#addForm').form("reset");
    $('#addWin').window('open');
}
//新建提交
function submitAddWin() {

    var name = $('#name').textbox('getValue');
    var description = $('#description').textbox('getValue');
    var status = $('#status').combobox('getValue');
    var remark = $('#remark').textbox('getValue');
    var insurance = $('#insurance').textbox('getValue');
    var carNum = $('#carNum').textbox('getValue');

    var flag = $('#carflag').textbox('getValue');

    if (name == '' || name.trim() == '') {
        $.messager.alert('提示', '车辆名称不能为空');
    }
    if (description == '' || description.trim() == '') {
        $.messager.alert('提示', '车辆描述不能为空');
    }
    if (status == '' || status.trim() == '') {
        $.messager.alert('提示', '车辆状态不能为空');
    }
    if (insurance == '' || insurance.trim() == '') {
        $.messager.alert('提示', '车辆保险不能为空');
    }
    if (carNum == '' || carNum.trim() == '') {
        $.messager.alert('提示', '车辆数量不能为空');
    }

    $('#addForm').form('submit', {
        url: '${ctx}/manage/car/addCar',
        success: function(data) {
            var data = eval('(' + data + ')');
            $.messager.alert('提示', data.msg);
            if (data.ret == 0) {
                $('#dg').datagrid('reload');
                $('#addWin').window('close');
                $('#addForm').form("reset");
            }
        },
        error: function(data) {
            $('#addWin').window('close');
        }
    });

}
//编辑
function showEditWin() {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        $('#edit-id').val(row.id);
        $('#edit-name').textbox('setValue', row.name);
        $('#edit-description').textbox('setValue', row.description);
        $('#edit-viewUrl').textbox('setValue', row.viewUrl);
        $('#edit-status').combobox('setValue', row.status);
        $('#edit-remark').textbox('setValue', row.remark);
        $('#edit-insurance').textbox('setValue', row.insurance);
        $('#edit-carNum').textbox('setValue', row.carNum);
        $('#editWin').window('open');
    } else {
        $.messager.alert('提示', '请先选中一行');
    }
}
//编辑提交
function submitEditWin(){
    var id = $('#edit-id').val();
    var name = $('#edit-name').textbox('getValue');
    var description = $('#edit-description').textbox('getValue');
    var status = $('#edit-status').combobox('getValue');
    var remark = $('#edit-remark').textbox('getValue');
    var insurance = $('#edit-insurance').textbox('getValue');
    var carNum = $('#edit-carNum').textbox('getValue');

    if (id == '' || id.trim() == '') {
        $.messager.alert('提示', '车辆ID为空，刷新页面重试，不行请联系John');
    }
    if (name == '' || name.trim() == '') {
        $.messager.alert('提示', '车辆名称不能为空');
    }
    if (description == '' || description.trim() == '') {
        $.messager.alert('提示', '车辆描述不能为空');
    }
    if (status == '' || status.trim() == '') {
        $.messager.alert('提示', '车辆状态不能为空');
    }
    if (insurance == '' || insurance.trim() == '') {
        $.messager.alert('提示', '车辆保险不能为空');
    }
    if (carNum == '' || carNum.trim() == '') {
        $.messager.alert('提示', '车辆数量不能为空');
    }

    $('#editForm').form('submit', {
        url: '${ctx}/manage/car/updateCar',
        success: function(data) {
            var data = eval('(' + data + ')');
            $.messager.alert('提示', data.msg);
            if (data.ret == 0) {
                $('#dg').datagrid('reload');
                $('#editWin').window('close');
                $('#editForm').form("reset");
            }
        },
        error: function(data) {
            $('#addWin').window('close');
        }
    });

}
//绑定
function showBindWin() {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        $('#bindCarId').textbox('setValue', row.id);
        $('#bindCarName').textbox('setValue', row.name);
        $('#bindCarDescription').textbox('setValue', row.description);
        $('#bindDeviceId').textbox('setValue', row.deviceId);
        $('#bindDeviceNumber').textbox('setValue', row.deviceNumber);
        $('#bindDeviceName').textbox('setValue', row.deviceName);
        $('#bindWin').window('open');

    } else {
        $.messager.alert('提示', '请先选中一行');
    }
}
//提交绑定
function submitBindWin(){
    var deviceId = $('#bindDeviceId').textbox('getValue');
    var deviceNumber = $('#bindDeviceNumber').textbox('getValue');
    var deviceName = $('#bindDeviceName').textbox('getValue');

    if (deviceId == '' || deviceId.trim() == '') {
        $.messager.alert('提示', '设备ID必填');
    }
    if (deviceNumber == '' || deviceNumber.trim() == '') {
        $.messager.alert('提示', '设备编号必填');
    }
    if (deviceName == '' || deviceName.trim() == '') {
        $.messager.alert('提示', '设备名称必填');
    }

    $('#bindForm').form('submit', {
        url: '${ctx}/manage/car/bindDevice',
        success: function(data) {
            var data = eval('(' + data + ')');
            $.messager.alert('提示', data.msg);
            if (data.ret == 0) {
                $('#dg').datagrid('reload');
                $('#bindWin').window('close');
                $('#bindForm').form("reset");
            }
        },
        error: function(data) {
            $('#bindWin').window('close');
        }
    });

}
//删除记录
function del() {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        $.messager.confirm('提示', '确定删除吗?', function(r){
            if (r){
                var paramz = {"id":row.id};
                $.post('${ctx}/manage/car/deleteCar', paramz, function(data, status){
                    if (data.ret == 0) {
                        $('#dg').datagrid('reload');
                    }
                }, 'json');
            }
        });
    } else {
        $.messager.alert('提示', '请先选中一行');
    }
}
//添加价格
function showAddPriceWin() {
    var row = $('#dg').datagrid('getSelected');
    if (row) {
        if (row.prices.length > 0) {
            $.messager.alert('提示', '请先删除已配置的价格');
            return false;
        }
        $('#rate-weekend').textbox('setValue', '100.00');
        $('#day1').textbox('setValue', '7');
        $('#rate1').textbox('setValue', '0.80');
        $('#day2').textbox('setValue', '15');
        $('#rate2').textbox('setValue', '0.70');
        $('#day3').textbox('setValue', '30');
        $('#rate3').textbox('setValue', '0.60');
        $('#topVipRate').textbox('setValue', '0.50');

        $('#price-car-id').val(row.id);
        $('#addPriceWin').window('open');
    } else {
        $.messager.alert('提示', '请先选中一行');
    }
}
//提交添加价格
function submitAddPriceWin(){
    var carId = $('#price-car-id').val();
//    var priceDesc = $('#price-name').textbox('getValue');
//    var priceDesc = '日常价';
    var price = $('#price').textbox('getValue');
    var rateWeekend = $('#rate-weekend').textbox('getValue');
    var rate1 = $('#rate1').textbox('getValue');
    var day1 = $('#day1').textbox('getValue');
    var rate2 = $('#rate2').textbox('getValue');
    var day2 = $('#day2').textbox('getValue');
    var rate3 = $('#rate3').textbox('getValue');
    var day3 = $('#day3').textbox('getValue');
    var topVipRate = $('#topVipRate').textbox('getValue');
//    var orderBy = $('#price-orderBy').textbox('getValue');

    if (carId == '' || carId.trim() == '') {
        $.messager.alert('提示', '车辆ID为空，刷新页面重试，不行请联系John');
    }
//    if (priceDesc == '' || priceDesc.trim() == '') {
//        $.messager.alert('提示', '价格描述不能为空');
//    }
    if (price == '' || price.trim() == '') {
        $.messager.alert('提示', '价格不能为空');
    }
    if (rateWeekend == '' || rateWeekend.trim() == '') {
        $.messager.alert('提示', '周末溢价不能为空');
    }
    if (day1 == '' || day1.trim() == '') {
        $.messager.alert('提示', '天数1不能为空');
    }
    if (rate1 == '' || rate1.trim() == '') {
        $.messager.alert('提示', '折扣1不能为空');
    }
    if (day2 == '' || day2.trim() == '') {
        $.messager.alert('提示', '天数2不能为空');
    }
    if (rate2 == '' || rate2.trim() == '') {
        $.messager.alert('提示', '折扣2不能为空');
    }
    if (day3 == '' || day3.trim() == '') {
        $.messager.alert('提示', '天数3不能为空');
    }
    if (rate3 == '' || rate3.trim() == '') {
        $.messager.alert('提示', '折扣3不能为空');
    }

    var paramz = {"carId":carId,"priceDesc":'日常价',"price":price,"rateWeekend":rateWeekend,
        "day1":day1,"rate1":rate1,"day2":day2,"rate2":rate2,"day3":day3,"rate3":rate3,
        "topVipRate":topVipRate};
    $.post('${ctx}/manage/car/addPrice', paramz, function(data, status){
        $.messager.alert('提示', data.msg);
        if (data.ret == 0) {
            $('#dg').datagrid('reload');
            $('#addPriceWin').window('close');
            $('#addPriceForm').form("reset");
        }
    }, 'json');
}
//删除价格
function delPrice(priceId) {
    $.messager.confirm('提示', '确定删除吗?', function(r){
        if (r){
            $.post('${ctx}/manage/car/deletePrice', {"id":priceId}, function(data, status){
                if (data.ret == 0) {
                    $('#dg').datagrid('reload');
                }
            }, 'json');
        }
    });
}
//格式化预览图片字段
function showBigImage(imgUrl, obj){
    var x = $(obj).offset().top;
    var y = $(obj).offset().left;
    $("#showBigImage img").attr("src", imgUrl);
    $("#showBigImage").css("display", "block");
    $("#showBigImage").css("top", x);
    $("#showBigImage").css("left", y + 70);
}
function hideBigImage(){
    $("#showBigImage").css("display","none");
}
</script>
</body>
</html>